<template>
  <view class="main">
    <CustomNavVue></CustomNavVue>
    <view class="title"> 快速拍出你的证件照 </view>
    <view class="title-min"> 一秒出图，无需漫长等待 </view>
    <view class="input">
      <image
        class="search-icon"
        src="/static//search-icon.png"
        mode="scaleToFill"
      />
      搜索你要找证件照名称
    </view>
    <view class="hot">
      <view class="left box">
        <image src="/static/example.jpg" mode="widthFix"></image>
        <view class="left-title"> 一寸照 </view>
        <view class="left-desc">
          <text>25*35mm</text>
          <text>295*413px</text>
        </view>
      </view>
      <view class="right">
        <view class="meiyan box">
          <view>
            <view class="right-title"> 一键美颜 </view>
            <view class="right-desc"> 已有照片快速修复 </view>
          </view>
        </view>
        <view class="customizeSize box">
          <view>
            <view class="right-title"> 自定义尺寸 </view>
            <view class="right-desc"> 自己设定照片尺寸 </view>
          </view>
        </view>
      </view>
    </view>
    <view class="banner">
      <image src="/static/banner.jpg" mode="widthFix"></image>
    </view>
    <liuyuno-tabs :tabData="tabs" @tabClick="tabClick" />
    <view class="tabs-box">
      <view
        class="card"
        v-for="item in activeTab"
        :key="item.index"
        @click="handleSubmit(item)"
      >
        <view class="card-title">{{ item.name }}</view>
        <view class="card-information">
          信息<text>{{ item.px[0] }}*{{ item.px[1] }}px</text>
        </view>
        <view class="card-information">
          宽高<text>{{ item.mm[0] }}*{{ item.mm[1] }}mm</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import CustomNavVue from "@/components/CustomNav.vue";
import liuyunoTabs from "@/components/liuyuno-tabs/liuyuno-tabs.vue";
import { tabs, sizes } from "@/utils/sizeSpecification";
export default {
  components: {
    CustomNavVue,
    liuyunoTabs,
  },
  data() {
    return {
      tabs: Object.freeze(tabs),
      activeTab: [],
    };
  },
  onLoad() {
    this.tabClick(0);
  },
  methods: {
    tabClick(index) {
      this.activeTab = sizes.filter((item) => item.id === index);
    },
    handleSubmit(item) {
      this.$store.commit("SETSPECIFICATION", item);
      uni.navigateTo({
        url: "/pages/index/specification",
      });
    },
  },
};
</script>

<style scoped lang="scss">
.main {
  background: linear-gradient(to bottom, transparent, #f5f5f5 30%),
    linear-gradient(to right, #b5e3fd 20%, #f3ffff);
  padding: 0 32rpx;
}

.title {
  font-size: 50rpx;
  font-weight: bold;
}

.title-min {
  color: #191816;
  margin-top: 12rpx;
}

.input {
  border: 4rpx solid #000;
  border-radius: 12rpx;
  padding: 12rpx 24rpx;
  color: #939393;
  margin-top: 24rpx;
  display: flex;
  align-items: center;
  .search-icon {
    width: 40rpx;
    height: 40rpx;
    margin-right: 12rpx;
  }
}

.hot {
  display: flex;
  gap: 24rpx;
  margin-top: 24rpx;

  .box {
    background-color: #fff;
    box-shadow: 0rpx 8rpx 12rpx 0rpx rgba(0, 0, 0, 0.05);
  }

  .left {
    width: 300rpx;
    border-radius: 12rpx;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 16rpx;

    image {
      width: 100%;
    }

    .left-title {
      font-size: 32rpx;
      color: #000;
      font-weight: bold;
      margin-left: 16rpx;
    }

    .left-desc {
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: #939393;
      font-size: 24rpx;
      margin: 0 16rpx;
    }
  }

  .right {
    display: flex;
    gap: 24rpx;
    flex-direction: column;
    flex: 1;

    .box {
      background-color: #fff;
      padding: 32rpx 24rpx;
      border-radius: 12rpx;
      display: flex;
      align-items: center;
      flex: 1;
      background-repeat: no-repeat;
      background-size: 150rpx 150rpx;
      background-position: right 20rpx;

      .right-title {
        font-size: 32rpx;
        font-weight: bold;
      }

      .right-desc {
        font-size: 24rpx;
        color: #939393;
        margin-top: 12rpx;
      }
    }

    .meiyan {
      background-image: url("/static/meiyan.jpg");
    }

    .customizeSize {
      background-image: url("/static/customize-icon.jpg");
    }
  }
}

.banner {
  border-radius: 12rpx;
  overflow: hidden;
  margin-top: 24rpx;
  box-shadow: 0rpx 8rpx 12rpx 0rpx rgba(0, 0, 0, 0.05);
  image {
    display: block;
    width: 100%;
  }
}

.tabs-box {
  margin: 24rpx 0;
  display: grid;
  gap: 24rpx;
  grid-template-columns: repeat(2, 1fr);
}
.card {
  padding: 24rpx 32rpx;
  background-color: #fff;
  border-radius: 12rpx;
  // margin-bottom: 12rpx;
  box-shadow: 0rpx 8rpx 12rpx 0rpx rgba(0, 0, 0, 0.05);

  .card-title {
    font-size: 28rpx;
    font-weight: bold;
  }
  .card-information {
    font-size: 24rpx;
    color: #939393;
    margin-top: 12rpx;
    text {
      color: #000;
      margin: 0 24rpx 0 12rpx;
    }
  }
}
</style>
